import os

'''
    :param path:String 路径
    :param oldName:String 源名称中需要替换的字符串
    :param replace:String 替换的字符串
    :param isRecursion:boolean 是否修改二级/三级...目录
'''


def rename(path, oldName, replace, isRecursion):
    dirList = os.listdir(path)
    for fileName in dirList:
        filterName = fileName.replace(oldName, replace)
        if filterName != fileName:
            os.rename(path+"\\"+fileName, path+"\\"+filterName)
        if os.path.isdir(path + "\\" + filterName) and isRecursion:
            rename(path + "\\" + filterName, oldName, replace, isRecursion)


if __name__ == '__main__':
    pass